var setTime_01,setTime;
/**
* obj 发送按钮对象
* type 短信发送类型1-注册
* sTime 允许在次发送的时间（秒）
*/
function sms_send(obj,type,sTime){
	var phone = $('#mobile').val();

	var phonePatter=/^13[0-9]{9}$|^15[0-9]{9}$|^18[0-9]{9}$|^17[0-9]{9}$/;
	if(!phonePatter.test(phone)){
		$('#sms_msg').text("手机号不正确");
		return ;
	}
	$.ajax({
		type:'get',//Get or Post
		url:'/handle.php',
		cache:false,//false
		dataType:'json',
		data:'h=user/sms_send&phone='+phone+'&type='+type,
		beforeSend:function(){
			$('#sms_msg').text("正在发送短息....");
			$(obj).attr('onclick','');
			$(obj).unbind('click');
		},
		success:function(data){

			clearInterval(setTime);
			clearInterval(setTime_01);
			if(!data.state&&!data.time){
				$('#sms_msg').text(data.msg);
				$(obj).bind('click',function (){
					sms_send($(this),type,sTime);
					return false;
				})
				return ;
			}
			if(data.time>0){
				var retime = data.time;
				setTime_01 = setInterval(function (){
					retime--;
					$('#sms_msg').text(retime+"秒后可重新发送");
					if(retime=='0') {
						$(obj).bind('click',function (){
							sms_send($(this),type,sTime);
							return false;
						})
						clearInterval(setTime_01);
						$('#sms_msg').text("");
					}
				},1000)

				return ;
			}else{
				var sms_retry_time = data.time>0?data.time:sTime;
				var time = sms_retry_time;
				setTime = setInterval(function (){
					time--;
					$('#sms_msg').text(time+"秒后可重新发送");
					if(time=='0'){
						$(obj).bind('click',function (){
							sms_send($(this),type);
							return false;
						})
						clearInterval(setTime);
						$('#sms_msg').text("");
					}
				},1000);

				return ;
			}
		}
	 });//Ajax End

}